<template>
  <div class="zlxg-page">
    <div class="primary-header clearfix flex flex-row align-center">
      <div class="line" />
      <span class="font18 ml10 flex-auto">填报人情况</span>
    </div>
    <div class="table-content">
      <el-descriptions class="margin-top" :column="3" border>
        <el-descriptions-item
          :span="1"
          :content-style="contentStyle"
          :label-style="labelStyle"
        >
          <template slot="label">
            当事人姓名
          </template>
          {{ formData.tbrqk_name }}
        </el-descriptions-item>
        <el-descriptions-item
          :span="1"
          :content-style="contentStyle"
          :label-style="labelStyle"
        >
          <template slot="label">
            部门
          </template>
          {{ formData.tbrqk_dept }}
        </el-descriptions-item>
        <el-descriptions-item
          :span="1"
          :content-style="contentStyle"
          :label-style="labelStyle"
        >
          <template slot="label">
            事件发生日期
          </template>
          {{ formData.tbrqk_fsrq }}
        </el-descriptions-item>
        <el-descriptions-item
          :span="1"
          :content-style="contentStyle"
          :label-style="labelStyle"
        >
          <template slot="label">
            院区
          </template>
          {{ formData.hospital }}
        </el-descriptions-item>
        <el-descriptions-item
          :span="2"
          :content-style="contentStyle"
          :label-style="labelStyle"
        >
          <template slot="label">
            发生地点
          </template>
          {{ formData.tbrqk_fsdd }}{{ formData.tbrqk_fsddqt }}
        </el-descriptions-item>
        <el-descriptions-item
          :span="1"
          :content-style="contentStyle"
          :label-style="labelStyle"
        >
          <template slot="label">
            报告类型
          </template>
          {{ formData.bglx | arrayString }} {{ formData.bglx_cd }}
        </el-descriptions-item>
        <el-descriptions-item
          :span="1"
          :content-style="contentStyle"
          :label-style="labelStyle"
        >
          <template slot="label">
            报告单位类别
          </template>
          {{ formData.bgdwlb }}
        </el-descriptions-item>
        <el-descriptions-item
          :span="1"
          :content-style="contentStyle"
          :label-style="labelStyle"
        >
          <template slot="label">
            编码
          </template>
          {{ formData.bgdw_bm }}
        </el-descriptions-item>
      </el-descriptions>
      <el-descriptions class="mt30" :column="3" border>
        <el-descriptions-item
          :span="1"
          :content-style="contentStyle"
          :label-style="labelStyle"
        >
          <template slot="label">
            患者姓名
          </template>
          {{ formData.sjsx_patient_name }}
        </el-descriptions-item>
        <el-descriptions-item
          :span="1"
          :content-style="contentStyle"
          :label-style="labelStyle"
        >
          <template slot="label">
            性别
          </template>
          {{ formData.patient_sex }}
        </el-descriptions-item>
        <el-descriptions-item
          :span="1"
          :content-style="contentStyle"
          :label-style="labelStyle"
        >
          <template slot="label">
            出生年月
          </template>
          {{ formData.patient_birth }}
        </el-descriptions-item>
        <el-descriptions-item
          :span="1"
          :content-style="contentStyle"
          :label-style="labelStyle"
        >
          <template slot="label">
            年龄
          </template>
          {{ formData.patient_age }}{{ formData.patient_age_unit }}
        </el-descriptions-item>
        <el-descriptions-item
          :span="1"
          :content-style="contentStyle"
          :label-style="labelStyle"
        >
          <template slot="label">
            民族
          </template>
          {{ formData.patient_mz }}
        </el-descriptions-item>
        <el-descriptions-item
          :span="1"
          :content-style="contentStyle"
          :label-style="labelStyle"
        >
          <template slot="label">
            体重
          </template>
          {{ formData.patient_weight }}
        </el-descriptions-item>
        <el-descriptions-item
          :span="1"
          :content-style="contentStyle"
          :label-style="labelStyle"
        >
          <template slot="label">
            联系方式
          </template>
          {{ formData.patient_phone }}
        </el-descriptions-item>
        <el-descriptions-item
          :span="1"
          :content-style="contentStyle"
          :label-style="labelStyle"
        >
          <template slot="label">
            入院时间
          </template>
          {{ formData.rytime }}
        </el-descriptions-item>
        <el-descriptions-item
          :span="1"
          :content-style="contentStyle"
          :label-style="labelStyle"
        >
          <template slot="label">
            原患疾病
          </template>
          {{ formData.yhjb }}
        </el-descriptions-item>
        <el-descriptions-item
          :span="1"
          :content-style="contentStyle"
          :label-style="labelStyle"
        >
          <template slot="label">
            医院名称
          </template>
          {{ formData.hb_hospital }}
        </el-descriptions-item>
        <el-descriptions-item
          :span="1"
          :content-style="contentStyle"
          :label-style="labelStyle"
        >
          <template slot="label">
            病历号/门诊号
          </template>
          {{ formData.hb_blh }}
        </el-descriptions-item>
        <el-descriptions-item
          :span="1"
          :content-style="contentStyle"
          :label-style="labelStyle"
        >
          <template slot="label">
            既往药品不良反应/事件
          </template>
          {{ formData.jwypbl }}{{ formData.jwypbl_detail }}
        </el-descriptions-item>
        <el-descriptions-item
          :span="1"
          :content-style="contentStyle"
          :label-style="labelStyle"
        >
          <template slot="label">
            家族药品不良反应/事件
          </template>
          {{ formData.jzypbl }}{{ formData.jzypbl_detail }}
        </el-descriptions-item>
        <el-descriptions-item
          :span="3"
          :content-style="contentStyle"
          :label-style="labelStyle"
        >
          <template slot="label">
            相关重要信息
          </template>
          {{ formData.xgzyxx | arrayString }}{{ formData.xgzyxxqt }}
        </el-descriptions-item>
      </el-descriptions>
    </div>
    <div class="primary-header clearfix flex flex-row align-center mt20">
      <div class="line" />
      <span class="font18 ml10 flex-auto">怀疑用药</span>
    </div>
    <div class="table-content">
      <drugTable :data="formData.suspectedDrug" />
    </div>
    <div class="primary-header clearfix flex flex-row align-center mt20">
      <div class="line" />
      <span class="font18 ml10 flex-auto">并用药品</span>
    </div>
    <div class="table-content">
      <drugTable :data="formData.togetherDrug" />
    </div>
    <div class="primary-header clearfix flex flex-row align-center mt20">
      <div class="line" />
      <span class="font18 ml10 flex-auto">事件详情</span>
    </div>
    <el-descriptions class="margin-top" :column="4" border>
      <el-descriptions-item
        :span="2"
        :content-style="contentStyle"
        :label-style="labelStyle"
      >
        <template slot="label">
          不良反应/事件名称
        </template>
        {{ formData.blsj_name }}
      </el-descriptions-item>
      <el-descriptions-item
        :span="2"
        :content-style="contentStyle"
        :label-style="labelStyle"
      >
        <template slot="label">
          不良反应/事件的结果
        </template>
        {{ formData.blfyjg }}
      </el-descriptions-item>
      <el-descriptions-item
        v-if="formData.blfyjg == '有后遗症'"
        :span="2"
        :content-style="contentStyle"
        :label-style="labelStyle"
      >
        <template slot="label">
          后遗症表现
        </template>
        {{ formData.hyzbx }}
      </el-descriptions-item>
      <el-descriptions-item
        v-if="formData.blfyjg == '死亡'"
        :span="2"
        :content-style="contentStyle"
        :label-style="labelStyle"
      >
        <template slot="label">
          直接死因
        </template>
        {{ formData.zjsy }}
      </el-descriptions-item>
      <el-descriptions-item
        v-if="formData.blfyjg == '死亡'"
        :span="2"
        :content-style="contentStyle"
        :label-style="labelStyle"
      >
        <template slot="label">
          死亡时间
        </template>
        {{ formData.dead_time }}
      </el-descriptions-item>
      <el-descriptions-item
        :span="4"
        :content-style="contentStyle"
        :label-style="labelStyle1"
      >
        <template slot="label">
          不良反应/事件过程描述(包括症状、体征、临床检验等)及处理情况(2000字之内)：
        </template>
        {{ formData.ypblfygc }}
      </el-descriptions-item>
      <el-descriptions-item
        :span="2"
        :content-style="contentStyle"
        :label-style="labelStyle1"
      >
        <template slot="label">
          停药或减量后反应/事件是否消失或减轻
        </template>
        {{ formData.tyjq }}
      </el-descriptions-item>
      <el-descriptions-item
        :span="2"
        :content-style="contentStyle"
        :label-style="labelStyle1"
      >
        <template slot="label">
          再次使用可疑药品后是否再次出现同样反应/事件
        </template>
        {{ formData.zcsykyywh }}
      </el-descriptions-item>
      <el-descriptions-item
        :span="2"
        :content-style="contentStyle"
        :label-style="labelStyle1"
      >
        <template slot="label">
          对原患疾病的影响
        </template>
        {{ formData.dyhbyx }}
      </el-descriptions-item>
      <el-descriptions-item
        :span="2"
        :content-style="contentStyle"
        :label-style="labelStyle1"
      >
        <template slot="label">
          用药与不良反应的出现有无合理的时间关系
        </template>
        {{ formData.ywhlsjgx }}
      </el-descriptions-item>
      <el-descriptions-item
        :span="2"
        :content-style="contentStyle"
        :label-style="labelStyle1"
      >
        <template slot="label">
          反应是否符合该药已知的不良反应类型
        </template>
        {{ formData.radio_1695550950000_3299 }}
      </el-descriptions-item>
      <el-descriptions-item
        :span="2"
        :content-style="contentStyle"
        :label-style="labelStyle1"
      >
        <template slot="label">
          反应是否可用并用药的作用、患者病情的进展、其他治疗的影响来解释
        </template>
        {{ formData.radio_1695551046000_75622 }}
      </el-descriptions-item>
    </el-descriptions>
    <div class="height60 text-center font18 line-height-60">报告人信息</div>
    <el-descriptions class="margin-top" :column="4" border>
      <el-descriptions-item :span="2" :label-style="labelStyle">
        <template slot="label">
          联系电话
        </template>
        {{ formData.bgrxx_phone }}
      </el-descriptions-item>
      <el-descriptions-item :span="2" :label-style="labelStyle">
        <template slot="label">
          电子邮件
        </template>
        {{ formData.bgrxx_email }}
      </el-descriptions-item>
      <el-descriptions-item :span="2" :label-style="labelStyle">
        <template slot="label">
          职业
        </template>
        {{ formData.bgrxx_zy }}
      </el-descriptions-item>
      <el-descriptions-item :span="2" :label-style="labelStyle">
        <template slot="label">
          签名
        </template>
        {{ formData.bgrxx_sign }}
      </el-descriptions-item>
      <el-descriptions-item :span="2" :label-style="labelStyle">
        <template slot="label">
          生产企业请填写信息来源
        </template>
        {{ formData.scqyxxly }}
      </el-descriptions-item>
      <el-descriptions-item :span="2" :label-style="labelStyle">
        <template slot="label">
          事件属性
        </template>
        {{ formData.sjsx }}
      </el-descriptions-item>
      <el-descriptions-item :span="4" :label-style="labelStyle2">
        <template slot="label">
          备注
        </template>
        {{ formData.remarks }}
      </el-descriptions-item>
    </el-descriptions>
    <div class="height60 text-center font18 line-height-60">关联性评价</div>
    <el-descriptions class="margin-top" :column="4" border>
      <el-descriptions-item :span="2" :label-style="labelStyle">
        <template slot="label">
          报告人
        </template>
        {{ formData.glx_bgrpj }}
      </el-descriptions-item>
      <el-descriptions-item :span="2" :label-style="labelStyle">
        <template slot="label">
          报告人签名
        </template>
        {{ formData.glx_bgrpjqm }}
      </el-descriptions-item>
      <el-descriptions-item :span="2" :label-style="labelStyle">
        <template slot="label">
          报告单位
        </template>
        {{ formData.glx_bgdw }}
      </el-descriptions-item>
      <el-descriptions-item :span="2" :label-style="labelStyle">
        <template slot="label">
          报告单位签名
        </template>
        {{ formData.glx_bgdwqm }}
      </el-descriptions-item>
      <el-descriptions-item :span="2" :label-style="labelStyle">
        <template slot="label">
          生产企业请填写信息来源
        </template>
        {{ formData.scqyxxly }}
      </el-descriptions-item>
      <el-descriptions-item :span="2" :label-style="labelStyle">
        <template slot="label">
          事件属性
        </template>
        {{ formData.sjsx }}
      </el-descriptions-item>
      <el-descriptions-item :span="4" :label-style="labelStyle2">
        <template slot="label">
          备注
        </template>
        {{ formData.remarks }}
      </el-descriptions-item>
      <el-descriptions-item :span="4" :label-style="labelStyle2">
        <template slot="label">
          附件
        </template>
        <div
          v-if="
            formData.file_1695551641000_83288 &&
              formData.file_1695551641000_83288.length > 0
          "
        >
          <div
            v-for="(item, index) in formData.file_1695551641000_83288"
            :key="index"
            class="value flex flex-row align-center mb10"
          >
            <el-link type="primary" :underline="false" class="width400">{{
              item.name
            }}</el-link>
            <el-button
              type="primary"
              size="small"
              class="ml30"
              icon="el-icon-download"
              @click="downFile(item)"
            >下载</el-button>
            <el-button
              v-if="item"
              type="primary"
              size="small"
              icon="el-icon-view"
              class="ml20"
              @click="previewFile(item)"
            >预览</el-button>
          </div>
        </div>
      </el-descriptions-item>
    </el-descriptions>
  </div>
</template>
<script>
import drugTable from './drugTable'
import axios from 'axios'
export default {
  name: 'Gycwsj',
  components: { drugTable },
  filters: {
    arrayString(val) {
      if (val && Array.isArray(val) && val.length > 0) {
        return val.join(',')
      } else {
        return ''
      }
    }
  },
  props: ['formData', 'createTime'],
  data() {
    return {
      contentStyle: {
        'text-align': 'left',
        'min-width': '180px'
      },
      // label样式
      labelStyle: { width: '130px' },
      labelStyle1: { 'min-width': '200px' },
      labelStyle2: { width: '130px' }
    }
  },

  computed: {},
  mounted() {},
  methods: {
    async downFile(item) {
      const filePath = item.url
      axios.get(filePath, { responseType: 'blob' }).then(res => {
        if (!res || !res.data) {
          ElMessage({
            type: 'warning',
            message: '文件下载失败'
          })
          return
        }

        var pos2 = filePath.lastIndexOf('/')
        const fileName = filePath.substring(pos2 + 1)
        const blob = new Blob([res.data], { type: 'application/pdf' })
        const downloadElement = document.createElement('a')
        const href = window.URL.createObjectURL(blob)
        downloadElement.href = href
        downloadElement.download = fileName
        document.body.appendChild(downloadElement)
        downloadElement.click()
        document.body.removeChild(downloadElement)
        window.URL.revokeObjectURL(href)
      })
    },
    previewFile(item) {
      var filePath = '' + item.url
      var pos = filePath.lastIndexOf('.')
      var extName = filePath.substring(pos + 1)
      extName = extName.toLowerCase()
      if (
        extName != 'pdf' &&
          extName != 'jpg' &&
          extName != 'jpeg' &&
          extName != 'png' &&
          extName != 'gif'
      ) {
        this.$messageS({
          type: 'warning',
          message: '上传的文件格式不支持预览'
        })
        return false
      }
      window.open(filePath)
    }
  }
}
</script>
  <style lang="scss" scoped></style>
